package com.waiting.thread;

/**
 * @Description
 * @Author bjweitingting
 * @Date 2019/2/20
 **/
public class ThreadLocalTest {
    private static ThreadLocal<Object> threadLocal = new ThreadLocal<>();
    private static ThreadLocal<Object> threadLocal_two= new ThreadLocal<>();

    public static class MyThread implements Runnable {
        @Override
        public void run() {
            threadLocal.set(Thread.currentThread().getName());
            System.out.println(threadLocal.get());
            threadLocal_two.set(Thread.currentThread().getId());
            System.out.println(threadLocal_two.get());
        }
    }

    public static void main(String[] args) {
        new Thread(new MyThread()).start();
        new Thread(new MyThread()).start();
    }
}
